package com.example.demo.domain.exam;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.demo.annotation.Display;
import com.example.demo.enums.ExamScoreStatus;
import com.example.demo.enums.SubmitType;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.sql.Timestamp;

@Data
@RequiredArgsConstructor
@TableName(value = "exam_user_score")
public class ExamUserScore {
    // 自动转string
    @Display("标识")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @Display("用户标识")
    @TableField(value = "user_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;

    @Display("用户名称")
    @TableField(value = "username")
    private String username;

    @Display("考试成绩")
    @TableField(value = "score")
    private Double score;

    @Display("所属班级标识")
    @TableField(value = "class_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long classId;

    @Display("考试标识")
    @TableField(value = "exam_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long examId;

    @Display("考试名称")
    @TableField(value = "exam_name")
    private String examName;

    @Display("所属班级名称")
    @TableField(value = "class_name")
    private String className;

    @Display("登录IP")
    @TableField(value = "ip")
    private String ip;

    @Display("进入考试时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "enter_time")
    private Timestamp enterTime;

    @Display("提交考试时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "submit_time")
    private Timestamp submitTime;

    @Display("用时(分)")
    @TableField(value = "time")
    private Long time;

    @Display("状态")
    @TableField(value = "status")
    private ExamScoreStatus status;

    @Display("是否提交")
    @TableField(value = "type")
    private SubmitType type;

}
